{% extends 'admin/base_site.html' %}
{% load i18n admin_urls static admin_list %}


{% block extrastyle %}
  {{ block.super }}
  <link rel="stylesheet" type="text/css" href="{% static "admin/css/changelists.css" %}" />
  {% if cl.formset %}
    <link rel="stylesheet" type="text/css" href="{% static "admin/css/forms.css" %}" />
  {% endif %}
  {% if cl.formset or action_form %}
    <script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
  {% endif %}
  {{ media.css }}
  {% if not actions_on_top and not actions_on_bottom %}
    <style>
      #changelist table thead th:first-child {width: inherit}
    </style>
  {% endif %}
{% endblock %}


{% block extrahead %}
{{ block.super }}
{{ media.js }}
{% endblock %}

{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-list{% endblock %}

{% if not is_popup %}
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
&rsaquo; <a href="/admin/metadata/hivetableinfo/">元数据管理</a>
&rsaquo; 搜索
</div>
{% endblock %}
{% endif %}

{% block coltype %}flex{% endblock %}

{% block content %}
  <div id="content-main">
      <form method='GET' action="/hive/search">
      <div class="row">
        <input type="text" name="search_key" value="{{ searchKey }}" size="100px" id="search_key" />
        <input type="submit" name="search_sub" value=" 搜 索 " />
      </div>
      </form>

     {% if contacts %}

          {% for result in contacts %}
          <div class="row list_row">
            <div class="row">
              <a href="{{ result.url }}" target="_blank"><strong>表名</strong>：{{ result.table_name|safe}}</a>
            </div>
            <div class="row">
              <strong>库名</strong>：{{ result.db_name}} <strong>表描述</strong>：{{ result.table_content|safe}}
            </div>
            <div class="row result_row">
            <strong>列描述</strong>：{{result.column_content|safe}}
            </div>
            <div class="row result_row">
           <strong>列字段</strong>：{{result.column_names|safe}}
            </div>

          </div>
          {% endfor %}

      {% else %}
          <div class="row list_row">
            没有查找到相关记录,可以试试换个条件
          </div>
      {% endif %}


    {% if contacts %}
       <div class="pagination">
            <span class="step-links">
                {% if contacts.has_previous %}
                    <a href="?search_key={{searchKey}}&page={{ contacts.previous_page_number }}">上一页</a>
                {% endif %}

                <span class="current">
                    Page {{ contacts.number }} of {{ contacts.paginator.num_pages }}.
                </span>

                {% if contacts.has_next %}
                    <a href="?search_key={{searchKey}}&page={{ contacts.next_page_number }}">下一页</a>
                {% endif %}
            </span>
        </div>
        {% endif %}

        <div class="submit-row">
        <!-- <input type="button" value="返回" id="column_history" onclick="return_metadata()" />-->
        </div>
  </div>
<style>

  .list_row{margin-bottom:15px; margin-top:15px;}
  .result_row{width:900px; word-wrap:break-word;}
</style>

<script>
function return_metadata(){
    window.location.href="/admin/metadata/hivetableinfo/"
}
</script>


{% endblock %}




